package com.csust.zerocode.service;

import com.csust.zerocode.model.dto.chathistory.ChatHistoryQueryRequest;
import com.csust.zerocode.model.entity.User;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.service.IService;
import com.csust.zerocode.model.entity.ChatHistory;
import dev.langchain4j.memory.ChatMemory;

import java.time.LocalDateTime;

/**
 *  服务层。
 *
 * @author 钰玟
 */
public interface ChatHistoryService extends IService<ChatHistory> {

    /**
     * 添加聊天消息至聊天记录
     * @param appId 应用ID
     * @param message 消息内容
     * @param messageType 消息类型
     * @param userId 用户ID
     * @return 是否添加成功
     */
    boolean addChatMessage(Long appId, String message, String messageType, Long userId);
    /**
     * 根据appId 删除对话历史
     * @param appId 应用ID
     * @return 是否删除成功
     */
    boolean deleteByAppId(Long appId);

    QueryWrapper getQueryWrapper(ChatHistoryQueryRequest chatHistoryQueryRequest);

    Page<ChatHistory> listAppChatHistoryByPage(Long appId, int pageSize,
                                               LocalDateTime lastCreateTime,
                                               User loginUser);

    int loadChatHistoryToMemory(Long appId, ChatMemory chatMemory, int maxHistorySize);
}
